import React from 'react';
import ReactDOM from 'react-dom';

import { Provider } from 'mobx-react';
import { createHashHistory } from 'history';
import { Router, Route, useRouterHistory } from 'react-router';
import { syncHistoryWithStore, RouterStore } from 'mobx-react-router';

import weaPortalLogin from 'weaPortalLogin';

const { store, Login } = weaPortalLogin;

const routing = new RouterStore();
const allStore = { routing, ...store };

const browserHistory = useRouterHistory(createHashHistory)({
  queryKey: '_key',
  basename: '/',
});

const history = syncHistoryWithStore(browserHistory, routing);
window.weaHistory = history;

const Root = () => (
  <Provider ecId={`${(this && this.props && this.props.ecId) || ''}_Provider@vhs3vo`} {...allStore}>
    <Router ecId={`${(this && this.props && this.props.ecId) || ''}_Router@lbh54i`} history={history}>
      <Route ecId={`${(this && this.props && this.props.ecId) || ''}_Route@co53h9`} path="/" component={Login} />
    </Router>
  </Provider>
);

ReactDOM.render(<Root ecId={`${(this && this.props && this.props.ecId) || ''}_Root@ta84au`} />, document.getElementById('container'));
